package edu.ubb.remeye.security;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Security types' enumeration.
 * 
 * @author Andrew Ianicicau
 *
 */
public enum SecurityType {

	///////////////////////////////////////////////////////////////////////////////////
	////		ATTRIBUTES - SecurityType
	///////////////////////////////////////////////////////////////////////////////////

	/**
	 * Security type invalid.
	 */
	INVALID,
	
	/**
	 * None security type.
	 */
	NONE,
	
	/**
	 * VNC security type.
	 */
	VNC;

	
	
	///////////////////////////////////////////////////////////////////////////////////
	////		METHODS - SecurityType
	///////////////////////////////////////////////////////////////////////////////////
	
	/**
	 * Returns the security type associated to the given ordinal.
	 * @param ordinal Security type ordinal.
	 * @return Security type associated to ordinal.
	 */
	public static SecurityType getSecurityType(int ordinal) {
		switch(ordinal) {
		case 0:
			return INVALID;
		case 1:
			return NONE;
		case 2:
			return VNC;
		default:
			return INVALID;
		}
	}
	
	/**
	 * Returns the list of security types available.
	 * @return The list of security types. 
	 */
	public static List<SecurityType> getSecurityTypeList() {
		List<SecurityType> list = new ArrayList<SecurityType>(); 
		list.addAll(Arrays.asList(SecurityType.values()));
		list.remove(0);
		return list;
	}
	
	/**
	 * Returns the security type if exists in the given list, otherwise invalid security type. 
	 * @param list The list of security types to use.
	 * @param type The security type to check for in the list.
	 * @return Security type or invalid.
	 */
	public static SecurityType listContains(List<SecurityType> list, SecurityType type) {
		if(list.contains(type))
			return type;
		return INVALID;
	}

}
